﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_form/Menu/dao_tao.master" AutoEventWireup="true" CodeFile="lop.aspx.cs" Inherits="App_form_Daotao_lop" %>

<%@ Register TagPrefix="Control" TagName="menu_phai" Src="~/App_ctr/Admin/menu_phai.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="width: 100%">
        <div style="width: 20%; float: left;">
            <Control:menu_phai runat="server" ID="menuphai" />
        </div>
        <div style="width: 79.4%; float: right; ">
            <div style="background-image: url(../../CSS/images/ui-bg_glass_75_e6e6e6_1x400.png); font-weight: bold; height: 30px; border: 1px solid #d3d3d3; margin-top: 4px; text-align: center; padding-top: 8px; text-transform: uppercase;">
                lớp học
            </div>
            <div style=" padding-left:100px; width:90%; border: 1px solid #d3d3d3; float:right; margin-top:3px;">
                <div id="ndung" style="width: 50%; float: left; padding-top: 100px;  ">
                    <div style="float: left; width: 20%;">
                        <label>
                            Hệ ĐT  :
                        </label>
                    </div>
                    <div>
                        <Lib:drop runat="server" ID="ht_dt" Width="308px" DataTextField="TEN" DataValueField="ID" Height="24" onClientChange="PDT_KHOA_LKE()"></Lib:drop>
                    </div>
                    <div style="width: 100%; height: 6px;"></div>
                    <div style="float: left; width: 20%;">
                        <label>
                            Khóa  :
                        </label>
                    </div>
                    <div>
                        <Lib:drop runat="server" ID="khoa" Width="308px" DataTextField="TEN" DataValueField="ID" Height="24" onClientChange="PDT_LOP_LKE()"></Lib:drop>
                    </div>
                    <div style="width: 100%; height: 6px;"></div>
                    <div style="float: left; width: 20%;">
                        <label>
                            Tên  :
                        </label>
                    </div>
                    <div>
                        <Lib:textBox runat="server" ID="ten" Width="300px"></Lib:textBox>
                    </div>
                    <div style="width: 100%; height: 6px;"></div>
                    <div style="float: left; width: 20%;">
                        <label>
                            Năm ĐT  :
                        </label>
                    </div>
                    <div>
                        <Lib:textBox runat="server" ID="nam_dt" Width="300px"></Lib:textBox>
                    </div>
                    <div style="width: 100%; height: 6px;"></div>
                    <div style="float: left; width: 100%; padding-left: 40px;">
                        <Lib:Button runat="server" ID="add" Text="Thêm mới" Width="100px" onClientClick="P_LOP_NH()"></Lib:Button>
                        <Lib:Button runat="server" ID="new" Text="Mới" Width="100px" onClientClick="P_LOP_MOI()"></Lib:Button>
                        <Lib:Button runat="server" ID="del" Text="Xóa" Width="100px" onClientClick="P_LOP_XOA()"></Lib:Button>
                    </div>
                    <div style="width: 100%; height: 10px;"></div>
                </div>
                <div style="width: 49%; float: left; padding-top: 5px;">
                    <Lib:gridView runat="server" ID="lop" Width="400" Height="350" onClientCellClick="LOP_CELL_CLICK">
                        <Columns>
                            <Lib:Column BaseColumn="TEN" Name="Tên" Width="385" />
                        </Columns>
                        <Pager>
                            <Lib:Pager PageSize="13" />
                        </Pager>
                    </Lib:gridView>
                </div>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="kthuoc" runat="server" Value="0,0" />
    <asp:HiddenField ID="id" runat="server" Value="0" />
    <script>
        //LKE KHOA
        function PDT_KHOA_LKE() {
            try {
                ht_dt = $("#<%=ht_dt.ClientID%>").val()
                wdt_ma.FDT_KHOA_LKE(ht_dt, P_KHOA_LKE_KQ, ErrorDb, ErrorTimeOut);
                return false;
            }

            catch (err) {
                ShowError(err);
            }
        }
        function P_KHOA_LKE_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var grid = GetDropByID("<%=khoa.ClientID%>");
            grid.dataBin(b_kq);
            P_LOP_MOI();
            PDT_LOP_LKE();
            return false;
        }
        //LKE
        function PDT_LOP_LKE() {
            try {
                b_khoa = $("#<%=khoa.ClientID%>").val();
                if (Common.NVL(b_khoa, "") == "")
                    b_khoa = 0.0;
                wdt_ma.FDT_LOP_LKE(b_khoa, P_LOP_LKE_KQ, ErrorDb, ErrorTimeOut);
            }

            catch (err) {
                ShowError(err);
            }
        }
        function P_LOP_LKE_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var grid = GetGridByID("<%=lop.ClientID%>");
            grid.dataBin(b_kq);
            return false;
        }

        function P_LOP_NH() {
            try {
                var ma = $("#<%=id.ClientID%>").val(), ten = $("#<%=ten.ClientID%>").val(), b_khoa = $("#<%=khoa.ClientID%>").val(),
                    nam = $("#<%=nam_dt.ClientID%>").val();
                wdt_ma.FDT_LOP_NH(ma, b_khoa, ten, nam, P_LOP_NH_KQ, ErrorDb, ErrorTimeOut);
                return false;
            }
            catch (err) {
                ShowError(err);
            }
        }

        function P_LOP_NH_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var a_kq = b_kq.split("#");
            var grid = GetGridByID("<%=lop.ClientID%>");
            var ma = a_kq[0];
            grid.dataBin(a_kq[1]);
            $("#<%=id.ClientID%>").val(ma);
            var b_hang = grid.getRowIndex(["ID"], [ma], ["=="]);
            if (b_hang >= 0)
                grid.setActiveRow(b_hang);
        }

        //MOI
        function P_LOP_MOI() {
            ResetForm("ndung");
            $("#<%=id.ClientID%>").val("0");
            var grid = GetGridByID("<%=lop.ClientID%>");
            grid.resetActiveRow();
        }

        //ACTIVE
        function LOP_CELL_CLICK(row, cell, val) {
            try {
                var grid = GetGridByID("<%=lop.ClientID%>");
                var aVal = grid.getValueActive(["ID", "TEN", "KHOA_ID", "NAMDT"]);
                if (aVal.MA == "")
                    return;
                $("#<%=id.ClientID%>").val(aVal.ID);
                $("#<%=ten.ClientID%>").val(aVal.TEN);
                $("#<%=nam_dt.ClientID%>").val(aVal.NAMDT);
            }
            catch (e)
            { Msg.Show("Thông báo", e.message, "error"); }
        }

        //XÓA
        function P_LOP_XOA() {
            try {
                var ma = $("#<%=id.ClientID%>").val();
                b_khoa = $("#<%=khoa.ClientID%>").val()
                if (ma == "") {
                    Msg.ShowError(e.message);
                    return;
                }
                wdt_ma.FDT_LOP_XOA(ma, ht_dt, P_LOP_XOA_KQ, ErrorDb, ErrorTimeOut);
            }
            catch (e) {
                ShowError(e.message);
            }
        }
        function P_LOP_XOA_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var grid = GetGridByID("<%=lop.ClientID%>");
            grid.dataBin(b_kq);
            var ma = $("#<%=id.ClientID%>").val()
            var b_hang = grid.getRowIndex(["ID"], [ma], ["<"]);
            if (b_hang >= 0)
                grid.setActiveRow(b_hang);
        }
    </script>
</asp:Content>

